package com.mud.dnd.frontend.rs;

import java.util.List;

import javax.ejb.EJB;
import javax.ejb.Stateless;

import com.mud.dnd.domain.common.DAOException;
import com.mud.dnd.domain.common.QueryParameter;
import com.mud.dnd.domain.model.Card;
import com.mud.dnd.domain.model.Comment;
import com.mud.dnd.domain.model.Deck;
import com.mud.dnd.ejb.CardManager;
import com.mud.dnd.ejb.CommentManager;
import com.mud.dnd.ejb.DeckManager;
import com.mud.dnd.ejb.UserManager;
import com.mud.dnd.ejb.common.AuthenticationException;

@Deprecated
@Stateless
public class EJBCallService {
	
	
	@EJB
	private CardManager cardManager;
	
	@EJB
	private DeckManager deckManager;
	
	@EJB
	private UserManager userManager;
	
	@EJB
	private CommentManager commentManager;

	public List<Card> getCards(List<QueryParameter> params) {
		
		

		return cardManager.getCards(params);
	}

	public int createCard(String name, String description, String pictureURL,
			 String type, int rarity, String userName, String sessionID) throws DAOException, AuthenticationException {
		return cardManager.createCard(name, description, pictureURL, type,rarity, userName,  sessionID);

	}
	
	public void addCardtoDeck(int cardID, int deckID, String userName, String sessionID) throws DAOException, AuthenticationException
	{
		cardManager.addCardtoDeck(cardID, deckID, userName,  sessionID);
	}
	
	public void updateCard(int id,String name, String description, String pictureURL,
			 String type,int rate, int rarity, String userName, String sessionID) throws DAOException, AuthenticationException {
		cardManager.updateCard(id, name, description, pictureURL, type, rate, rarity, userName,  sessionID);

	}
	
	public void removeCardfromDeck(int cardID, int deckID, String userName, String sessionID) throws DAOException, AuthenticationException
	{
		cardManager.removeCardfromDeck(cardID, deckID, userName,  sessionID);
	}
	
	public void deleteCard(int id, String userName, String sessionID) throws DAOException, AuthenticationException {
		cardManager.deleteCard(id, userName,  sessionID);

	}
	

	public List<Deck> getDecks(List<QueryParameter> params) {

		return deckManager.getDecks( params);
	}

	public int createDeck(String name, String description, String pictureURL, String userName, String sessionID) throws AuthenticationException, DAOException {
		return deckManager.createDeck(name, description, pictureURL, userName,  sessionID);
	}
	
	public void updateDeck(int id,String name, String description, String pictureURL, int rate, String userName, String sessionID) throws DAOException, AuthenticationException {
		deckManager.updateDeck(id, name, description, pictureURL, rate, userName,  sessionID);
	}
	
	public void deleteDeck(int id, String userName, String sessionID) throws DAOException, AuthenticationException
	{
		deckManager.deleteDeck(id, userName,  sessionID);
	}
	
	
	
	public String loginUser(String name, String password) throws DAOException,
			AuthenticationException {
		
		return userManager.loginUser(name, password);

	}

	public int createUser(String name, String password) throws DAOException, AuthenticationException {
		return userManager.createUser(name, password);
	}

	
	public void deleteUser(String name, String targetName, String sessionID) throws DAOException, AuthenticationException{
		userManager.deleteUser(name, targetName, sessionID);
	}

	
	public void logoutUser(String name, String sessionID) throws DAOException,
			AuthenticationException {
		userManager.logoutUser(name, sessionID);
	}
	
	public int addComment(String message, String userName, int gameItemID, String sessionID) throws DAOException, AuthenticationException
	{
		return commentManager.addComment(message, userName, gameItemID, sessionID);
	}
	
	public void deleteComment(int commentID,String userName,String sessionID ) throws DAOException, AuthenticationException
	{
		commentManager.deleteComment(commentID, userName, sessionID);
	}
	
	public List<Comment> getComments(List<QueryParameter> params) 
	{
		return commentManager.getComments(params);
	}

}
